

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The processes module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.processes">
<span id="the-processes-module"></span><h1>The processes module<a class="headerlink" href="#module-pyamp.processes" title="Permalink to this headline">¶</a></h1>
<p>The processes module contains modules and classes pertaining to
managing systems with multiple processes.</p>
<div class="section" id="the-coroutine-function">
<h2>The coroutine function<a class="headerlink" href="#the-coroutine-function" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="pyamp.processes.coroutine">
<tt class="descclassname">pyamp.processes.</tt><tt class="descname">coroutine</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#pyamp.processes.coroutine" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator to create a coroutine and call next on it.</p>
<ul class="simple">
<li>function &#8211; The function to decorate</li>
</ul>
</dd></dl>

</div>
<div class="section" id="the-thread-class">
<h2>The Thread class<a class="headerlink" href="#the-thread-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pyamp.processes.Thread">
<em class="property">class </em><tt class="descclassname">pyamp.processes.</tt><tt class="descname">Thread</tt><big>(</big><em>conditionFn=&lt;function &lt;lambda&gt; at 0x912e224&gt;</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#pyamp.processes.Thread" title="Permalink to this definition">¶</a></dt>
<dd><p>The Thread class provides a base class for creating threaded classes. It
is essentially a wrapper for the <a class="reference external" href="http://docs.python.org/library/threading.html#threading.Thread" title="(in Python v2.7)"><tt class="docutils literal"><span class="pre">threading.Thread</span></tt></a> class to make
threaded classes easier to manage.</p>
<p>It provides the following functions that can be overridden by subclasses:</p>
<ul>
<li><p class="first">onStart(self) &#8211; This function is called when the Thread is started.</p>
</li>
<li><dl class="first docutils">
<dt>onException(self, e, trace) &#8211; This function is called in the event that</dt>
<dd><p class="first last">an exception is encountered while the
Thread is cycling.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>onCycle(self, increment) &#8211; This function is called once each time the</dt>
<dd><p class="first last">Thread cycles.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>onShutdown(self) &#8211; This function is called in the event that the Thread</dt>
<dd><p class="first last">is shutdown.</p>
</dd>
</dl>
</li>
</ul>
<p>Once the Thread has started it continues to run until the <a class="reference internal" href="#pyamp.processes.Thread.shutdown" title="pyamp.processes.Thread.shutdown"><tt class="xref py py-func docutils literal"><span class="pre">shutdown()</span></tt></a>
function is called, or until the condition function returns False.</p>
<p>Subclasses can set the Period property which sets the number of seconds
that the Thread will sleep at the end of each cycle. The default value is
one millisecond.</p>
<p>This class implements the <a class="reference internal" href="logging.html#pyamp.logging.Loggable" title="pyamp.logging.Loggable"><tt class="xref py py-class docutils literal"><span class="pre">pyamp.logging.Loggable</span></tt></a> interface.</p>
<ul class="simple">
<li>conditionFn &#8211; A function that determines when the Thread should exit</li>
<li>logger &#8211; The logger for this class</li>
</ul>
<dl class="method">
<dt id="pyamp.processes.Thread.isRunning">
<tt class="descname">isRunning</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.isRunning" title="Permalink to this definition">¶</a></dt>
<dd><p>Determine if the Thread is still running.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.onCycle">
<tt class="descname">onCycle</tt><big>(</big><em>increment</em><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.onCycle" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called when at each cycle of the Thread and should
be overridden by subclasses.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by concrete Threads.</p>
</div>
<ul class="simple">
<li>increment &#8211; The current increment number</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.onException">
<tt class="descname">onException</tt><big>(</big><em>e</em>, <em>trace</em><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.onException" title="Permalink to this definition">¶</a></dt>
<dd><p>The Thread encountered an exception.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by concrete Threads.</p>
</div>
<ul class="simple">
<li>e &#8211; The exception</li>
<li>trace &#8211; The traceback for the exception</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.onShutdown">
<tt class="descname">onShutdown</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.onShutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called when the Thread is shut down and should
be overridden by subclasses.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by concrete Threads.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.onStart">
<tt class="descname">onStart</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.onStart" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called when the Thread is started and should
be overridden by subclasses.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by concrete Threads.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.onStop">
<tt class="descname">onStop</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.onStop" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is called when the Thread is stopped.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by concrete Threads.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Run the Thread until it is shut down or its condition function
returns False.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Thread.shutdown">
<tt class="descname">shutdown</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Thread.shutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Shutdown the Thread.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-cycle-class">
<h2>The Cycle class<a class="headerlink" href="#the-cycle-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pyamp.processes.Cycle">
<em class="property">class </em><tt class="descclassname">pyamp.processes.</tt><tt class="descname">Cycle</tt><big>(</big><em>conditionFn</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#pyamp.processes.Cycle" title="Permalink to this definition">¶</a></dt>
<dd><p>The Cycle class provides a class which will continue cycling until
a condition is no longer True.</p>
<ul class="simple">
<li>conditionFn &#8211; The condition function</li>
<li>logger &#8211; The logger object</li>
</ul>
<dl class="method">
<dt id="pyamp.processes.Cycle.shutdown">
<tt class="descname">shutdown</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Cycle.shutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Stop cycling.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.processes.Cycle.start">
<tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#pyamp.processes.Cycle.start" title="Permalink to this definition">¶</a></dt>
<dd><p>Start cycling until the condition function returns False.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The processes module</a><ul>
<li><a class="reference internal" href="#the-coroutine-function">The coroutine function</a></li>
<li><a class="reference internal" href="#the-thread-class">The Thread class</a></li>
<li><a class="reference internal" href="#the-cycle-class">The Cycle class</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/processes.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>